package com.hmall.util;


import com.hmall.common.dto.User;

public class UserThreadLocal {
    private UserThreadLocal() {
    }

    private static final ThreadLocal<User> LOCAL = new ThreadLocal<>();

    /**
     * 添加用户
     *
     * @param user 用户
     */
    public static void put(User user) {
        LOCAL.set(user);
    }

    /**
     * 获得用户信息
     *
     * @return {@link User}
     */
    public static User get() {
        return LOCAL.get();
    }

    /**
     * 删除用户
     */
    public static void remove() {
        LOCAL.remove();
    }
}
